var $ = require("jquery");

var miniAdd = {
    setFormValue: function(item) {
        var data = this.state.data;
        data[item.name] = item.value;
        this.setState({
            data
        });
    },
    changState: function(value) {
        return this.setState(value);
    },
    getState: function(name) {
        return this.state[name];
    },
    vaInData: function(data) {

        var key, state = this.state,
            temp, newState = {},
            isVa = true;
        for (key in state) {
            temp = state[key];
            console.log('temp::::', key, '====>>>', temp);
            if (temp && temp.title && temp.errorMessage != true && temp.isStar) {
                console.log(temp);
                temp.errorMessage = temp.errorMessage == false ? "不能为空" : temp.errorMessage;
                newState[key] = temp;
                isVa = false;
            }
        }
        this.setState(newState);
        if (isVa) {
            this.formate(this.copyData(this.state.data), data);
        }
    },
    copyData: function(obj) {
        return $.extend(true, {}, obj);
    }
}


module.exports = miniAdd;